package vn.student.Adapter;

import static vn.student.database.DBComman.CONTENT;
import static vn.student.database.DBComman.TIME;
import static vn.student.database.DBComman.TITLE;
import vn.student.database.SQLDataHelper;
import vn.student.notificationforandroid.CreateCanhanActivity;
import vn.student.notificationforandroid.R;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;

public class PageCaNhan extends LinearLayout {
    LayoutInflater layoutInflater;
    View v;
    ListView mListView;
    AdapterCanhan mAdapterCanhan;
    final String TAG = "NAME COLUMN";
    Cursor c;
    Button btCreateCanhan;
    public PageCaNhan(final Activity context, SQLDataHelper mSQLHelp) {
	super(context);
	this.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
		LayoutParams.FILL_PARENT));
	layoutInflater = LayoutInflater.from(context);
	v = layoutInflater.inflate(R.layout.page_canhan, null, true);
	this.addView(v, getLayoutParams());
	long row=mSQLHelp.insertCanhan("hello viet nam abc asfafasf", "15/7/2012", "Cong hoa xa hoi chu nghia viet nam doc lap tu do hanh phuc ban kiem diem", null, 1);
	Log.d(TAG, "vua them vao dong+"+row);
	c = mSQLHelp.getALLCanhan();
	context.startManagingCursor(c);
	mListView = (ListView) findViewById(android.R.id.list);
	mAdapterCanhan = new AdapterCanhan(context, R.layout.row_page_canhan,
		c, new String[] { TITLE, TIME, CONTENT }, new int[] {
			R.id.row_canhan_title, R.id.row_canhan_time,
			R.id.row_canhan_context });
	mListView.setAdapter(mAdapterCanhan);
	btCreateCanhan= (Button)findViewById(R.id.btCreate);
	btCreateCanhan.setOnClickListener(new OnClickListener() {
	    
	    public void onClick(View v) {
		context.startActivity(new Intent(context, CreateCanhanActivity.class));
		
	    }
	});
    }

    public View getView() {
	return this;
    }
    
    
}
